
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Data;
using Andromeda.Global.Business;
using Andromeda.Global.Data.Db;
using Andromeda.Global.Common;
using ForgeIt.Dal.dbo.Validator;

  
namespace ForgeIt.Dal.dbo.Stub
{
	internal abstract class DBLicenseInformationStub : dboSchema
	{
		#region private fields

		/// <summary>
		/// (fieldname, datatype, ischangeable(!isidentity), isinsertable(!isidentity), isforeignkey, foreigntable
		/// </summary>

		protected readonly DbField foIdLicenseInformation = new DbField("IdLicenseInformation", DbType.Int32, true, true, false, false, false, "");

		protected readonly DbField foIdLicense = new DbField("IdLicense", DbType.Int32, false, false, true, true, true, "License");

		protected readonly DbField foName = new DbField("Name", DbType.String, false, false, true, true, false, "");

		protected readonly DbField foValue = new DbField("Value", DbType.String, false, false, true, true, false, "");

		protected readonly DbField foImageValue = new DbField("ImageValue", DbType.Binary, false, false, true, true, false, "");

  
        #region local cache - Foreign Keys

        protected DBLicense localIdLicense;
  

        #endregion local cache - Foreign Keys


        #endregion private fields

        #region constructors

        protected DBLicenseInformationStub()
		{
		}

		protected DBLicenseInformationStub(bool ignorethis, string foName, string foValue, byte[] foImageValue, Int32 foIdLicense)
		{

			this.foName.Value = foName;

			this.foValue.Value = foValue;

			this.foImageValue.Value = foImageValue;

			this.foIdLicense.Value = foIdLicense;

		}
	
		#endregion constructors
    
		#region public properties
		
		public override DbConnector CleanEntity
		{
			get { return new DBLicenseInformation(); }
		}


		public int IdLicenseInformation
		{
			get { return ObjectConverter.ToInt32(foIdLicenseInformation.Value); }
		}

		public int IdLicense
		{
			get { return ObjectConverter.ToInt32(foIdLicense.Value); }
			set { foIdLicense.Value = value; }
		}

		public string Name
		{
			get { return ObjectConverter.ToString(foName.Value); }
			set { foName.Value = value; }
		}

		public string Value
		{
			get { return ObjectConverter.ToString(foValue.Value); }
			set { foValue.Value = value; }
		}

		public byte[] ImageValue
		{
			get { return ObjectConverter.ToByteArray(foImageValue.Value); }
			set { foImageValue.Value = value; }
		}

  
		public override string TableName
		{
			get { return "LicenseInformation"; }
		}



        #region Foreign Keys
      
        /// <summary>
        /// Getter method for Object encapsulated view of foreign key
        /// </summary>
        public virtual DBLicense GetFK_IdLicense()
        {
          return localIdLicense ?? (localIdLicense = DBLicense.GetEntity(IdLicense));
        }
        /// <summary>
        /// Setter method for Object encapsulated view of foreign key
        /// </summary>        
        public virtual void SetFK_IdLicense(DBLicense paramIdLicense)
        {
          localIdLicense = paramIdLicense;
          IdLicense = paramIdLicense.IdLicense;
        }
      
        #endregion Foreign Keys


		    protected override ValidationModelBase Validator
		    {
			    get { return new DBLicenseInformationValidator(); }
		    }
		#endregion public properties
    
		#region enumerator

		/// <summary>
		/// This enumerator contains a list of all the fields of the datasource
		/// </summary>
		public enum FieldNames
		{
			IdLicenseInformation,
			IdLicense,
			Name,
			Value,
			ImageValue,

		}

		#endregion enumerator
    
		#region generic field methods

		/// <summary>
		/// Validates if a given  field value is a DbNull
		/// </summary>
		/// <param name="fieldName">The field to validate</param>
		///<returns>true if is DbNull, false otherwise</returns>
		public bool IsDbNull(FieldNames fieldName)
		{
			switch (fieldName)
			{

				case FieldNames.IdLicenseInformation: return (foIdLicenseInformation.Value is DBNull);

				case FieldNames.IdLicense: return (foIdLicense.Value is DBNull);

				case FieldNames.Name: return (foName.Value is DBNull);

				case FieldNames.Value: return (foValue.Value is DBNull);

				case FieldNames.ImageValue: return (foImageValue.Value is DBNull);

			}

			throw new InvalidDataException();
		}

		/// <summary>
		/// Sets the given field value to DbNull
		/// </summary>
		/// <param name="fieldName">The field to set</param>
		public void SetDbNull(FieldNames fieldName)
		{
			switch (fieldName)
			{

				case FieldNames.IdLicenseInformation:
					foIdLicenseInformation.Value = DBNull.Value; break;

				case FieldNames.IdLicense:
					foIdLicense.Value = DBNull.Value; break;

				case FieldNames.Name:
					foName.Value = DBNull.Value; break;

				case FieldNames.Value:
					foValue.Value = DBNull.Value; break;

				case FieldNames.ImageValue:
					foImageValue.Value = DBNull.Value; break;

			}
		}
		
		#endregion generic field methods
    
        #region static factories

		/// <summary>
		/// Creates a new DB object that can be added to the database as a new row
		/// </summary>
		/// <returns>The instance of the DB Object</returns>
		public static DBLicenseInformation NewRow
		{
			get { return new DBLicenseInformation(); }
		}

		/// <summary>
		/// Returns multiple rows from the Datasource by a given set of WHERE clause fields, only includes fields where value != null
		/// </summary>
		/// <example>List of fields to filter by, null to ignore field (null = all).</example>
		/// <returns>A collection with the filtered results. </returns>
		internal static IEnumerable<DBLicenseInformation> ListEntity(object foIdLicenseInformation, object foIdLicense, object foName, object foValue, object foImageValue)
		{
			DBLicenseInformation helper = new DBLicenseInformation();
			

			helper.foIdLicenseInformation.Value = foIdLicenseInformation;

			helper.foIdLicense.Value = foIdLicense;

			helper.foName.Value = foName;

			helper.foValue.Value = foValue;

			helper.foImageValue.Value = foImageValue;


			return helper.GetEntityInstancesList(helper.Fields.ToArray()).Cast<DBLicenseInformation>();
        }

		/// <summary>
		/// Returns multiple rows from the Datasource by a given set of WHERE clause fields, only includes fields where value != null
		/// </summary>
		/// <example>List of fields to filter by, null to ignore field (null = all).</example>
		/// <returns>A collection with the filtered results. </returns>
		internal static IEnumerable<DBLicenseInformation> ListEntity()
		{
			return new DBLicenseInformation().GetEntityInstancesList(new DbField[0]).Cast<DBLicenseInformation>();
        }

      		/// <summary>
		/// Returns a single row from the datasource by a given set of RUID strong-typed values
		/// </summary>
		/// <returns>The instance for this key or a new one if no match is found.</returns>
		internal static DBLicenseInformation GetEntity(int foIdLicenseInformation)
		{
			DBLicenseInformation helper = new DBLicenseInformation();

			helper.foIdLicenseInformation.Value = foIdLicenseInformation;

			helper = helper.GetEntityInstance(helper.Ruid) as DBLicenseInformation;
			
			return helper;
		}


        /// <summary>
        /// Returns multiple rows from the Datasource that referentiate a specific foreign object 
        /// </summary>
        /// <param name="foIdLicense">The <see cref="DBLicense"/> object to filter by.</param>
        /// <returns>A collection with the filtered results.</returns>
        public static  IEnumerable<DBLicenseInformation> ListEntityIdLicense(DBLicense foIdLicense)
        {
          DBLicenseInformation helper = new DBLicenseInformation();

          helper.foIdLicense.Value = foIdLicense.IdLicense;

          return helper.GetEntityInstancesList(helper.foIdLicense).Cast<DBLicenseInformation>();
        }

		#endregion static factories
	}
}